home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
OLE2BOOK.ZIP
/
CHAP13.ZIP
/
PATRON
/
PATRON.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-19
|
12KB
|
387 lines
/*
* PATRON.H
* Modifications for Chapter 13
*
* Single include file that pulls in everything needed for other source
* files in the application.
*
* Copyright (c)1993 Microsoft Corporation, All Rights Reserved
*
* Kraig Brockschmidt, Software Design Engineer
* Microsoft Systems Developer Relations
*
* Internet : kraigb@microsoft.com
* Compuserve: >INTERNET:kraigb@microsoft.com
*/
#ifndef _PATRON_H_
#define _PATRON_H_
#include <windows.h>
#include <ole2.h>
#include <ole2ver.h>
#include <ole2ui.h>
#include <bookguid.h>
extern "C"
{
#include <commdlg.h>
#include <print.h>
}
#include <classlib.h>
#include "resource.h"
#include "pages.h"
//PATRON.CPP: Frame object that creates a main window
class __far CPatronFrame : public CFrame
{
//CHAPTER13MOD
//For access to m_pCL for document creation
friend class CLinkClassFactory;
//End CHAPTER13MOD
private:
BOOL m_fInitialized; //OleInitialize worked
//CHAPTER13MOD
BOOL m_fEmbedding; //-Embedding on command line?
DWORD m_dwRegCO; //From CoRegisterClassObject
LPCLASSFACTORY m_pIClassFactory;
//End CHAPTER13MOD
protected:
//Overridable for creating a CPatronClient
virtual LPCClient CreateCClient(void);
virtual BOOL FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
virtual BOOL FRegisterAllClasses(void);
//CHAPTER13MOD
virtual BOOL FPreShowInit(void);
virtual void ParseCommandLine(void);
//End CHAPTER13MOD
virtual UINT CreateGizmos(void);
virtual LRESULT OnCommand(HWND, WPARAM, LPARAM);
public:
CPatronFrame(HINSTANCE, HINSTANCE, LPSTR, int);
virtual ~CPatronFrame(void);
//Overrides
BOOL FInit(LPFRAMEINIT);
virtual void UpdateMenus(HMENU, UINT);
virtual void UpdateGizmos(void);
};
typedef CPatronFrame FAR * LPCPatronFrame;
//CHAPTER13MOD
//These are global for simplification of object implementation.
extern ULONG g_cObj;
extern ULONG g_cLock;
extern HWND g_hWnd;
//Type for an object-destroyed callback
typedef void (FAR PASCAL *LPFNDESTROYED)(void);
//Function for the object to notify on destruction.
void FAR PASCAL ObjectDestroyed(void);
//ICLASSF.CPP
class __far CLinkClassFactory : public IClassFactory
{
protected:
ULONG m_cRef;
LPCPatronFrame m_pFR; //For document creation.
public:
CLinkClassFactory(LPCPatronFrame);
~CLinkClassFactory(void);
//IUnknown members
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//IClassFactory members
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
STDMETHODIMP LockServer(BOOL);
};
typedef CLinkClassFactory FAR * LPCLinkClassFactory;
//End CHAPTER13MOD
//CLIENT.CPP
/*
* The only reason we have a derived class here is to override
* CreateCDocument so we can create our own type as well as
* overriding NewDocument to perform one other piece of work once the
* document's been created.
*/
class __far CPatronClient : public CClient
{
protected:
//Overridable for creating a new CDocument
virtual LPCDocument CreateCDocument();
public:
CPatronClient(HINSTANCE);
virtual ~CPatronClient(void);
};
typedef CPatronClient FAR * LPCPatronClient;
//DOCUMENT.CPP
//Constant ID for the pages window that lives in a document window
#define ID_PAGES 723
//CHAPTER13MOD
/*
* To support linking to embeddings, the document needs to have
* IPersistFile and IOleItemContainer interfaces, so we multiply
* inherit from IUnknown and provide two interface implementations.
*/
class __far CPatronDoc : public CDocument, public IUnknown
//End CHAPTER13MOD
{
//These need access to FQueryPasteFromData, FPasteFromData
friend class CDropTarget;
friend class CDropSource;
//CHAPTER13MOD
friend class CImpIPersistFile;
friend class CImpIOleItemContainer;
//End CHAPTER13MOD
protected:
LONG m_lVer; //Loaded data version
LPCPages m_pPG; //Pages window in us.
LPSTORAGE m_pIStorage; //Root storage for document.
BOOL m_fPrintSetup; //Enable printer setup if no tenants.
class CDropTarget FAR *m_pDropTarget; //Registered target.
UINT m_cfEmbeddedObject; //Clipboard formats
UINT m_cfObjectDescriptor;
UINT m_cfLinkSource;
UINT m_cfLinkSrcDescriptor;
BOOL m_fShowTypes; //Show Objects active?
//CHAPTER13MOD
ULONG m_cRef;
BOOL m_fRename; //Rename on USave?
DWORD m_dwRegROT;
LPPERSISTFILE m_pIPersistFile;
LPOLEITEMCONTAINER m_pIOleItemContainer;
//End CHAPTER13MOD
protected:
virtual BOOL FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
BOOL FQueryPasteFromData(LPDATAOBJECT, LPFORMATETC, LPTENANTTYPE);
BOOL FQueryPasteLinkFromData(LPDATAOBJECT, LPFORMATETC, LPTENANTTYPE);
BOOL FPasteFromData(LPDATAOBJECT, LPFORMATETC, TENANTTYPE
, LPPATRONOBJECT, DWORD, BOOL);
public:
CPatronDoc(HINSTANCE);
virtual ~CPatronDoc(void);
//CHAPTER13MOD
//We now need our ubiquitous set of IUnknown members.
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//End CHAPTER13MOD
virtual BOOL FInit(LPDOCUMENTINIT);
virtual void Clear(void);
virtual BOOL FDirtyGet(void);
virtual void Delete(void);
virtual BOOL FQueryPrinterSetup(void);
virtual BOOL FQueryObjectSelected(HMENU);
virtual UINT ULoad(BOOL, LPSTR);
virtual UINT USave(UINT, LPSTR);
virtual BOOL Print(HWND);
virtual UINT PrinterSetup(HWND, BOOL);
virtual BOOL FClip(HWND, BOOL);
virtual BOOL FQueryPaste(void);
virtual BOOL FPaste(HWND);
virtual BOOL FPasteSpecial(HWND);
virtual BOOL FQueryEnableEditLinks(void);
virtual BOOL FEditLinks(HWND);
virtual BOOL FShowOrQueryObjectTypes(BOOL, BOOL);
virtual UINT NewPage(void);
virtual UINT DeletePage(void);
virtual UINT NextPage(void);
virtual UINT PreviousPage(void);
virtual UINT FirstPage(void);
virtual UINT LastPage(void);
virtual void Rename(LPSTR);
virtual BOOL FInsertObject(HWND);
virtual void ActivateObject(UINT);
};
typedef CPatronDoc FAR * LPCPatronDoc;
//CHAPTER13MOD
//IPersistFile implementation for CPatronDoc
class __far CImpIPersistFile : public IPersistFile
{
protected:
ULONG m_cRef; //Interface reference count.
LPCPatronDoc m_pDoc; //Back pointer to the object.
LPUNKNOWN m_punkOuter; //Controlling unknown for delegation.
public:
CImpIPersistFile(LPCPatronDoc, LPUNKNOWN);
~CImpIPersistFile(void);
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
STDMETHODIMP GetClassID(LPCLSID);
STDMETHODIMP IsDirty(void);
STDMETHODIMP Load(LPCSTR, DWORD);
STDMETHO